package com.zhang.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Arrays;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zhang.domain.ArticleComment;
import com.zhang.service.IArticleCommentService;
import xin.altitude.cms.common.entity.AjaxResult;
import java.util.List;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import xin.altitude.cms.common.entity.PageEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import com.zhang.mapper.ArticleCommentMapper;
@RestController
@RequestMapping("/zhang/article/comment")
public class ArticleCommentController{
    @Autowired
    private IArticleCommentService articleCommentService;
    @GetMapping("/page")
    public AjaxResult page(PageEntity pageEntity,ArticleComment articleComment){
        return AjaxResult.success(articleCommentService.page(pageEntity.toPage(), Wrappers.lambdaQuery(articleComment)));
    }
    @GetMapping("/list")
    public AjaxResult list(ArticleComment articleComment){
        return AjaxResult.success(articleCommentService.list(Wrappers.lambdaQuery(articleComment)));
    }
    @PostMapping("/push")
    public AjaxResult add(@RequestBody ArticleComment articleComment) {
        return AjaxResult.success(articleCommentService.save(articleComment));
    }
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody ArticleComment articleComment) {
        return AjaxResult.success(articleCommentService.updateById(articleComment));
    }
    @DeleteMapping("/delete/{ids}")
    public AjaxResult delete(@PathVariable Long[] ids) {
        return AjaxResult.success(articleCommentService.removeByIds(Arrays.asList(ids)));
    }
    @GetMapping(value = "/detail/{id}")
    public AjaxResult detail(@PathVariable("id") Long id) {
        return AjaxResult.success(articleCommentService.getById(id));
    }
    @GetMapping("/vo/page")
    public AjaxResult pageVo(PageEntity pageEntity,ArticleComment articleComment){
        return AjaxResult.success(articleCommentService.pageVo(pageEntity.toPage(), articleComment));
    }
    @GetMapping("/vo/list")
    public AjaxResult listVo(ArticleComment articleComment){
        return AjaxResult.success(articleCommentService.listVo(articleComment));
    }
    @GetMapping(value = "/vo/detail/{id}")
    public AjaxResult detailVo(@PathVariable("id") Long id) {
        return AjaxResult.success(articleCommentService.getOneVo(id));
    }
}
